/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */

package es.citic.puedes.youtube.testhelp;

import java.util.List;

import es.citic.puedes.youtube.IYouTubeManager;
import es.citic.puedes.youtube.YouTubeAuthException;
import es.citic.puedes.youtube.YouTubeException;
import es.citic.puedes.youtube.model.YouTubeContact;
import es.citic.puedes.youtube.model.YouTubeUser;
import es.citic.puedes.youtube.test.YouTubeManagerTest;

public class YouTubeContactsTest {

	public static void runYouTubeGetContactsTest(IYouTubeManager ytm, Integer userId) throws SecurityException, YouTubeException, YouTubeAuthException {
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}

		// gets user profile
		YouTubeUser user = ytm.getUserProfile(userId);

		// gets contacts
		List<YouTubeContact> contactList = ytm.getContacts(user);
		YouTubePrinterTestMethods.printContactList(contactList,user.getUserName());
	}

	public static void runYouTubeAddContactsTest(IYouTubeManager ytm, Integer userId, String newUsername) throws SecurityException, YouTubeException, YouTubeAuthException {
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}

		// gets user profile
		YouTubeUser user = ytm.getUserProfile(userId);

		// adds a contact
		ytm.addContact(user, "drakodga");
		List<YouTubeContact> contactList = ytm.getContacts(user);
		YouTubePrinterTestMethods.printContactList(contactList,user.getUserName());
	}

	public static void runYouTubeDeleteContactsTest(IYouTubeManager ytm, Integer userId, String username) throws SecurityException, YouTubeException, YouTubeAuthException {
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}

		// gets user profile
		YouTubeUser user = ytm.getUserProfile(userId);

		// adds a contact
		try {
			ytm.addContact(user, "drakodga");
		} catch (Exception e1) {
			// Nothing to do
		}

		// deletes a contact
		try {
			ytm.deleteContact(user, "drakodga");
		} catch (Exception e) {
			// TODO: handle exception
		}

		List<YouTubeContact> contactList = ytm.getContacts(user);
		YouTubePrinterTestMethods.printContactList(contactList,user.getUserName());
	}
}
